package com.cdtye.itps.cms.dao.detect;

import com.baomidou.mybatisplus.annotation.*;
import com.cdtye.itps.cms.dao.defect.entity.JcwProblemDefectLevel;
import com.cdtye.itps.cms.dao.enums.DelFlagEnum;
import com.google.gson.Gson;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.experimental.Accessors;

import java.util.Date;

/**
 * @Author: wang lei
 * @Date: 2021/10/10 11:22
 * @Description:
 */
@ApiModel("接触网缺陷等级")
@Data
@Accessors(chain = true)
@TableName("JCW_DEFECT_GRADE")
public class JcjcDefectGradeSection {

    private static final long serialVersionUID = 1L;


    /**
     * 缺陷等级名称
     */
    @TableField("DEFECT_GRADE_NAME")
    private String defectGradeName;

    /**
     * 缺陷等级编码
     */
    @TableField("LEVEL_CODE")
    private String levelCode;

    /**
     * 整改期限
     */
    @TableField("SOLVE_DAYS")
    private Integer solveDays;

    /**
     * 提醒期限
     */
    @TableField("REMIND_TIME_COUNT")
    private Integer remindTimeCount;

    /**
     * 描述
     */
    @TableField("REMARK")
    private String remark;

    /**
     * 排序号
     */
    @TableField("SORT_NUM")
    private Integer sortNum;

    @TableId(value = "DEFECT_GRADE_ID", type = IdType.ASSIGN_UUID)
    private String defectGradeId;

    @ApiModelProperty("创建时间")
    @TableField(value ="CREATE_DATETIME", fill = FieldFill.INSERT)
    private Date createDatetime;

    @ApiModelProperty("更新时间")
    @TableField(value ="UPDATE_DATETIME",fill = FieldFill.INSERT_UPDATE)
    private Date updateDatetime;

    @ApiModelProperty("删除标志，Y=是，N=否")
    @TableField(value ="DEL_FLAG", fill = FieldFill.INSERT)
    private String delFlag;

    @ApiModelProperty("创建人")
    @TableField(value ="CREATE_BY", fill = FieldFill.INSERT)
    private String createBy;

    @ApiModelProperty("更新人")
    @TableField(value ="UPDATE_BY",fill = FieldFill.INSERT_UPDATE)
    private String updateBy;

    public JcwProblemDefectLevel covEntity() {
        Gson gs = new Gson();
        String listStr = gs.toJson(this);
        JcwProblemDefectLevel jcwProblemDefectLevelBureau = gs.fromJson(listStr, JcwProblemDefectLevel.class);
        jcwProblemDefectLevelBureau.setLevelName(this.defectGradeName);
//        jcwProblemDefectLevelBureau.setSortNum(Long.valueOf(this.sortNum));
        jcwProblemDefectLevelBureau.setUpdateDatetime(new Date());
        jcwProblemDefectLevelBureau.setCreateDatetime(new Date());
        jcwProblemDefectLevelBureau.setId(null);
        return jcwProblemDefectLevelBureau;
    }
}
